/*
 * @Description: 用户相关
 * @Version: 1.0
 * @Autor: wangqiang
 * @Date: 2021-07-01 10:04:10
 * @LastEditors: wangqiang
 * @LastEditTime: 2021-07-01 11:23:49
 */
import { Module } from 'vuex';
import { UserInfosState, RootStateTypes } from '@/store/interface';

const userInfosModule: Module<UserInfosState, RootStateTypes> = {
	state: {
        isLogin: false,
        token: ''
	},
	mutations: {
		// 设置用户信息
		setToken(state: any, token: string) {
			state.token = token;
		},
		setLogin(state: any, isLogin: string) {
			state.isLogin = isLogin
		}
	},
	actions: {
		// 设置用户信息
		asyncSetLogin({ commit }, isLogin: boolean) {
			return new Promise((resolve: any) => {
				commit('setLogin', isLogin)
				resolve()
			})
		}
	}
};

export default userInfosModule;
